{if $this->operate == 'Index'}
{template header}
<script type="text/javascript">
var commonAddUrl 	= '{:U('product/add')}';
var commonEditUrl	= '{:U('product/edit')}';
</script> 
<div class="loading3" id="loading3">加载中...</div>
<div id="header-menu" attr="产品管理">
  <div class="menu-btn" onclick="window.location.href='{:U('product/add')}';"> <a href="javascript:;">添加</a>
    <div class="menu-btn-l"></div>
    <div class="menu-btn-r"></div>
  </div>
</div>
<div class="clear"></div>
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="title-1 c-item" width="30">ID</td>
    <td class="title-1 c-item" width="150">类别</td>
    <td class="title-1 c-item">标题</td>
    <td class="title-1 c-item" width="120">语言</td>
    <td class="title-1 c-item" width="120">查看</td>
    <td class="title-2 c-item" width="150">操作</td>
  </tr>
</table>
<div id="main-body">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
  {loop $list $key $vo}
  <tr>
    <td class="td-0 c-item" height="20" width="24">{$vo['id']}</td>
    <td class="td-1 c-item" width="144">{$vo['category']}</td>
    <td class="td-1">{$vo['topic']}</td>
    <td class="td-1 c-item" width="114">{$vo['lang']}</td>
    <td class="td-1 c-item" width="114">{$vo['views']}</td>
    <td class="td-2 c-item" width="144"><a href="{:U('product/edit?id='.$vo['id'])}">修改</a> 删除</td>
  </tr>
  {/loop}
</table>
</div>
<div class="bottom-bar">
  <div class="page">{$pageHtml}</div>
</div>
<div class="clear"></div>
{template footer}
{elseif $this->operate == 'Add'}
{template header}
<script type="text/javascript" src="{PUB}Editor/editor_config.js"></script>
<script type="text/javascript" src="{PUB}Editor/editor_all_min.js"></script>
<link rel="stylesheet" type="text/css" href="{PUB}Editor/themes/default/ueditor.css" />
<div class="loading3" id="loading3">加载中...</div>
<div id="header-menu" attr="添加产品">
  <div class="menu-btn" onclick="window.location.href='{:U('product/add')}';"> <a href="javascript:;">添加</a>
    <div class="menu-btn-l"></div>
    <div class="menu-btn-r"></div>
  </div>
</div>
<div class="clear"></div>
<form name="myform" id="myform" method="post" action="{:U('product/add')}" enctype="multipart/form-data">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="title-0 c-item" colspan="2">添加产品</td>
  </tr>
</table>
<div id="main-body">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="td-0-1" width="80" height="20" align="right">标题：</td>
    <td class="td-1"><input type="text" name="data[topic]" id="topic" size="30" class="input-1" /></td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">分类：</td>
    <td class="td-1">
    <select name="pid" id="pid" onchange="selectCategory();">
    <option value="">=请选择=</option>
    {loop $pid_list $k $v}
    <option value="{$v['id']}">{$v['name']}</option>
    {/loop}
    </select>
    <span id="smallCategory"></span>
    </td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">语言：</td>
    <td class="td-1">
    <select name="data[lang_id]" id="lang_id">
    <option value="">=请选择=</option>
    {loop $lang_item $key $v}
    <option value="{$key}">{$v}</option>
    {/loop}
    </select>
    </td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">封面图片：</td>
    <td class="td-1"><input type="file" name="defaultpic" size="40" class="input-1" /></td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">详细内容：</td>
    <td class="td-1">
    <script type="text/plain" id="myEditor" style="width:700px"></script>
	<script type="text/javascript">
	var editor = new baidu.editor.ui.Editor();
	editor.render( 'myEditor' );
    </script>
    </td>
  </tr>
</table>
</div>
<div class="bottom-bar">
  <input type="submit" name="btn" value="保存" class="sbtn" />
</div>
</form>
<script type="text/javascript">
selectCategoryUrl	= '{:U('product/selectcategory')}';
function showRequest(formData, jqForm, options) { 
	$("#loading3").show();
	$("#loading3").html('加载中...');
    return true; 
} 
// post-submit callback 
function showResponse(responseText, statusText, xhr)  { 
	var vo = eval("("+responseText+")");
	$("#loading3").html(vo.msg);
	if (vo.status == 1) {
		setTimeout(function(){
			window.location.href='{:U('product')}';
		},1000);
	} 
	return false;
}
var options = { 
    beforeSubmit:  showRequest, 
    success:       showResponse
}; 
$('#myform').submit(function() { 
   $(this).ajaxSubmit(options); 
   return false; 
});
</script>
<div class="clear"></div> 
{template footer}
{elseif $this->operate == 'Edit'}
{template header}
<script type="text/javascript" src="{PUB}Editor/editor_config.js"></script>
<script type="text/javascript" src="{PUB}Editor/editor_all_min.js"></script>
<link rel="stylesheet" type="text/css" href="{PUB}Editor/themes/default/ueditor.css" />
<div class="loading3" id="loading3">加载中...</div>
<div id="header-menu" attr="添加产品">
  <div class="menu-btn" onclick="window.location.href='{:U('product/add')}';"> <a href="javascript:;">添加</a>
    <div class="menu-btn-l"></div>
    <div class="menu-btn-r"></div>
  </div>
</div>
<div class="clear"></div>
<form name="myform" id="myform" method="post" action="{:U('product/edit?id='.$vo['id'])}" enctype="multipart/form-data">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="title-0 c-item" colspan="2">编辑产品</td>
  </tr>
</table>
<div id="main-body">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="td-0-1" width="80" height="20" align="right">标题：</td>
    <td class="td-1"><input type="text" name="data[topic]" id="topic" value="{$vo['topic']}" size="30" class="input-1" /></td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">分类：</td>
    <td class="td-1">
    <select name="pid" id="pid" onchange="selectCategory();">
    <option value="">=请选择=</option>
    {loop $pid_list $k $v}
    <option value="{$v['id']}"{if $pid==$v['id']} selected="selected"{/if}>{$v['name']}</option>
    {/loop}
    </select>
    <span id="smallCategory">
    <select name="data[category_id]">
    {loop $small_list $k $v}
    <option value="{$v['id']}"{if $vo['category_id']==$v['id']} selected="selected"{/if}>{$v['name']}</option>
    {/loop}
    </select>
    </span>
    </td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">语言：</td>
    <td class="td-1">
    <select name="data[lang_id]" id="lang_id">
    <option value="">=请选择=</option>
    {loop $lang_item $key $v}
    <option value="{$key}"{if $vo['lang_id']==$key} selected="selected"{/if}>{$v}</option>
    {/loop}
    </select>
    </td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">封面图片：</td>
    <td class="td-1"><input type="file" name="defaultpic" size="40" class="input-1" /> <input type="hidden" name="defaultpicbak" value="{$vo['defaultpic']}" /><a href="{$vo['defaultpic']}" target="_blank">查看原图</a></td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">详细内容：</td>
    <td class="td-1">
    <script type="text/plain" id="myEditor" style="width:700px">{$vo['content']}</script>
	<script type="text/javascript">
	var editor = new baidu.editor.ui.Editor();
	editor.render( 'myEditor' );
    </script>
    </td>
  </tr>
</table>
</div>
<div class="bottom-bar">
  <input type="submit" name="btn" value="保存" class="sbtn" />
</div>
</form>
<script type="text/javascript">
selectCategoryUrl	= '{:U('product/selectcategory')}';
function showRequest(formData, jqForm, options) { 
	$("#loading3").show();
	$("#loading3").html('加载中...');
    return true; 
} 
// post-submit callback 
function showResponse(responseText, statusText, xhr)  { 
	var vo = eval("("+responseText+")");
	$("#loading3").html(vo.msg);
	if (vo.status == 1) {
		setTimeout(function(){
			window.location.href='{:U('product')}';
		},1000);
	} 
	return false;
}
var options = { 
    beforeSubmit:  showRequest, 
    success:       showResponse
}; 
$('#myform').submit(function() { 
   $(this).ajaxSubmit(options); 
   return false; 
});
</script>
<div class="clear"></div> 
{template footer}
{elseif $this->operate == 'Category'}
{template header}
<script type="text/javascript">
var commonAddUrl 	= '{:U('product/addcategory')}';
var commonEditUrl	= '{:U('product/editcategory')}';
</script> 
<div class="loading3" id="loading3"></div>
<div id="header-menu" attr="类别管理">
  <div class="menu-btn" id="add"> <a href="javascript:;">添加</a>
    <div class="menu-btn-l"></div>
    <div class="menu-btn-r"></div>
  </div>
</div>
<div class="clear"></div>
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td class="title-1 c-item" width="30">ID</td>
    <td class="title-1 c-item">说明</td>
    <td class="title-1 c-item" width="120">语言</td>
    <td class="title-2 c-item" width="150">操作</td>
  </tr>
</table>
<div id="main-body">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
  {loop $list $key $vo}
  <tr>
    <td class="td-0 c-item" height="20" width="24">{$vo['id']}</td>
    <td class="td-1">{$vo['name']}</td>
    <td class="td-1 c-item" width="114">{$vo['lang_str']}</td>
    <td class="td-2 c-item" width="144"><a href="javascript:;" onclick="commonEdit({$vo['id']})">修改</a> 删除</td>
  </tr>
  {if $vo['_child']}
  {loop $vo['_child'] $k $v}
  <tr>
    <td class="td-0 c-item" height="20" width="24">{$v['id']}</td>
    <td class="td-1" style="padding-left:20px;color:#0CF;">{$v['name']}</td>
    <td class="td-1 c-item" width="114">{$v['lang_str']}</td>
    <td class="td-2 c-item" width="144"><a href="javascript:;" onclick="commonEdit({$v['id']})">修改</a> 删除</td>
  </tr>
  {/loop}
  {/if}
  {/loop}
</table>
</div>
<div class="bottom-bar">
  &nbsp;
</div>
<div class="clear"></div>
{template footer}
{elseif $this->operate == 'Addcategory'}
<form name="myform" id="myform" method="post" action="{:U('product/addcategory')}">
<table border="0" align="center" width="400" cellpadding="0" cellspacing="0">
  <tr>
    <td class="title-0 c-item" colspan="2">添加类别</td>
  </tr>
  <tr>
    <td class="td-0-1" width="30%" height="20" align="right">类别名称：</td>
    <td class="td-1"><input type="text" name="data[name]" id="name" size="30" class="input-1" /></td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">所属语言：</td>
    <td class="td-1">
    <select name="data[lang_id]" id="lang_id">
    <option value="">=请选择=</option>
    {loop $lang_item $k $v}
    <option value="{$k}">{$v}</option>
    {/loop}
    </select>
    </td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">所属大类：</td>
    <td class="td-1">
    <select name="data[pid]" id="pid">
    <option value="0">=作为顶级分类=</option>
    {loop $pid_list $k $v}
    <option value="{$v['id']}">{$v['name']}</option>
    {/loop}
    </select>
    </td>
  </tr>
</table>
</form>
<div class="loading2" id="loading2"></div>
{elseif $this->operate == 'Editcategory'}
<form name="myform" id="myform" method="post" action="{:U('product/editcategory?id='.$vo['id'])}">
<table border="0" align="center" width="400" cellpadding="0" cellspacing="0">
  <tr>
    <td class="title-0 c-item" colspan="2">编辑类别</td>
  </tr>
  <tr>
    <td class="td-0-1" width="30%" height="20" align="right">类别名称：</td>
    <td class="td-1"><input type="text" name="data[name]" id="name" value="{$vo['name']}" size="30" class="input-1" /></td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">所属语言：</td>
    <td class="td-1">
    <select name="data[lang_id]" id="lang_id">
    <option value="">=请选择=</option>
    {loop $lang_item $k $v}
    <option value="{$k}"{if $vo['lang_id']==$k} selected="selected"{/if}>{$v}</option>
    {/loop}
    </select>
    </td>
  </tr>
  <tr>
    <td class="td-0-1" height="20" align="right">所属大类：</td>
    <td class="td-1">
    <select name="data[pid]" id="pid">
    <option value="0">=作为顶级分类=</option>
    {loop $pid_list $k $v}
    <option value="{$v['id']}"{if $vo['pid']==$v['id']} selected="selected"{/if}>{$v['name']}</option>
    {/loop}
    </select>
    </td>
  </tr>
</table>
<div class="loading2" id="loading2"></div>
</form>
{/if}